<?php
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Services\GoodsService;
use Illuminate\Http\Request;


class GoodsController extends Controller
{
    private static $goodsService;

    public function __construct(GoodsService $goodsService)
    {
        self::$goodsService = $goodsService;
    }

    /**
     * 获取商品列表展示
     * User: zhouyao
     * Date: 2018/8/28
     * Time: 下午9:21
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\AppException
     */
    public function index(Request $request)
    {
        $input = $request->all();
        $param = json_decode($input['param'], true);
        $result = self::$goodsService->goodsList($param);
        return app_response(200, $result);
    }

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\AppException
     */
    public function detail(Request $request)
    {
        $input = $request->all();
        $param = json_decode($input['param'], true);
        $result = self::$goodsService->goodsDetail($param);
        return app_response(200, $result);
    }

}